﻿function mouseOverMarker() {
    this.ui = $("<div></div>");
    this.ui.addClass("column");
    this.ui.css("left", 50);
    this.ui.css("top", 50);
    this.ui.css("z-index", 1000);
    this.ui.css("border", "1px solid yellow");
    this.ui.css("opacity", .5);
    this.cells = [];
    $("#mapArea").append(this.ui);
    this._elevation = 0;
    this.elevation = function (p) {
        if (p === undefined) {
            return this._elevation;
        } else {
            this._elevation = p;
            this.x(this._x);
            this.y(this._y);
            var zX = 0;
            var zY = 0;
            if (this._x < centerX) {
                this.ui.css("width", cellSize * zoom + this._elevation * cellSize * zoom / fov);
                this.ui.css("left", centerPixelX + (this._x - centerX) * (cellSize * zoom) - cellSize * zoom / 2 - this._elevation * cellSize * zoom / fov);
                zX = this._x - leftStart;
            } else if (this._x > centerX) {
                this.ui.css("width", cellSize * zoom + this._elevation * cellSize * zoom / fov);
                zX = rightEnd - this._x;
            } else {
                this.ui.css("width", cellSize * zoom + 2 * this._elevation * cellSize * zoom / fov);
                this.ui.css("left", centerPixelX + (this._x - centerX) * (cellSize * zoom) - cellSize * zoom / 2 - this._elevation * cellSize * zoom / fov);
                zX = centerX - leftStart;
            }
            if (this._y < centerY) {
                this.ui.css("height", cellSize * zoom + this._elevation * cellSize * zoom / fov);
                this.ui.css("top", centerPixelY + (this._y - centerY) * (cellSize * zoom) - cellSize * zoom / 2 - this._elevation * cellSize * zoom / fov);
                zY = this._y - topStart;
            } else if (this._y > centerY) {
                this.ui.css("height", cellSize * zoom + this._elevation * cellSize * zoom / fov);
                zY = bottomEnd - this._y;
            } else {
                this.ui.css("height", cellSize * zoom + 2 * this._elevation * cellSize * zoom / fov);
                this.ui.css("top", centerPixelY + (this._y - centerY) * (cellSize * zoom) - cellSize * zoom / 2 - this._elevation * cellSize * zoom / fov);
                zY = centerY - topStart;
            }
            this.ui.html("");
            this.cells = [];
            for (var i = this._elevation; i >= 1; i--) {
                this.cells[i] = $("<div></div>");
                this.cells[i].addClass("cell");
                this.cells[i].css("width", cellSize * zoom);
                this.cells[i].css("height", cellSize * zoom);
                if (this._x < centerX) {
                    this.cells[i].css("left", i * cellSize * zoom / fov);
                } else if (this._x > centerX) {
                    this.cells[i].css("left", (this._elevation - i) * cellSize * zoom / fov);
                } else {
                    this.cells[i].css("left", i * cellSize * zoom / fov);
                    this.cells[i].css("width", cellSize * zoom + 2 * (this._elevation - i) * cellSize * zoom / fov);
                }
                if (this._y < centerY) {
                    this.cells[i].css("top", i * cellSize * zoom / fov);
                } else if (this._y > centerY) {
                    this.cells[i].css("top", (this._elevation - i) * cellSize * zoom / fov);
                } else {
                    this.cells[i].css("top", i * cellSize * zoom / fov);
                    this.cells[i].css("height", cellSize * zoom + 2 * (this._elevation - i) * cellSize * zoom / fov);
                }
                this.cells[i].css("z-index", this.ui.css("z-index"));
                this.cells[i].css("background-image", resource);
                this.cells[i].data("foo", this);
                this.ui.append(this.cells[i]);
            }
        }
    }
    this._x = 0;
    this.x = function (p) {
        if (p === undefined) {
            return this._x;
        } else {
            this._x = p;
            this.ui.css("left", centerPixelX + (this._x - centerX) * (cellSize * zoom) - cellSize * zoom / 2);
        }
    }
    this._y = 0;
    this.y = function (p) {
        if (p === undefined) {
            return this._y;
        } else {
            this._y = p;
            this.ui.css("top", centerPixelY + (this._y - centerY) * (cellSize * zoom) - cellSize * zoom / 2);
        }
    }
    this.elevation(0);
}